package com.best.testprogressbar;

import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    private HorizontalProgressBarWithProgress mHorizontalProgressBarWithProgress;
    private static final int MSG_UPDATE = 0X110;

    private RoundProgressBarWidthProgress mRoundProgressBarWidthProgress;


    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            int progress = mHorizontalProgressBarWithProgress.getProgress();
            mHorizontalProgressBarWithProgress.setProgress(++progress);
            mRoundProgressBarWidthProgress.setProgress(++progress);
            if (progress > 100) {
                mHandler.removeMessages(MSG_UPDATE);
            }
            mHandler.sendEmptyMessageDelayed(MSG_UPDATE, 100);
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mHorizontalProgressBarWithProgress = (HorizontalProgressBarWithProgress) findViewById(R.id.progressbar_01);
        mRoundProgressBarWidthProgress = (RoundProgressBarWidthProgress) findViewById(R.id.progressbar_02);
        mHandler.sendEmptyMessage(MSG_UPDATE);
    }
}
